<?php
 
$notif_agenda="no";
$notif_update="no";

foreach($user->result_array() as $row){
	$notif_agenda=$row['notif_agenda'];
	$notif_update=$row['notif_update'];
}
?>

<section id="content" class="grid_7 alpha omega">
<article>
<h1>Notifikasi</h1>
<div class="success" style="display:none">Success</div>
<div class="error" style="display:none">Error</div>
<form id="form" action="<?php echo base_url()."setting/notif"?>" class="styled" method="post" enctype="multipart/form-data" >	
		
		<div class="grid_7 left">
			<label for="name">Email saya ketika :</label>
			<input type="checkbox" name="data[notif_agenda]" <?php echo $notif_agenda=="yes"?'checked="checked"':''?> value="yes" />&nbsp;Ada agenda kajian dan agenda lain yang update
			<br />
			<input type="checkbox" name="data[notif_update]" <?php echo $notif_update=="yes"?'checked="checked"':''?> value="yes" />&nbsp;Ada informasi dan/atau komentar update yang berkaitan dengan saya
			<br />
			<br />
			<input type="submit" value="SIMPAN" class="right button" />
			
		</div>
</form>
</article>
</section>

<script>				
$(document).ready(function(){

	$("#form").validationEngine();
	
});

$("#form").submit(function(){
	if($(this).validationEngine('validate')){
		var formInput = $(this).serialize();
		
		$.ajax({
			url: $(this).attr('action'),
			data: formInput,
			beforeSend : function(){
				$.fancybox.showActivity();
				$(".error").hide();
			},
			success: function(respon){
				var obj = jQuery.parseJSON(respon);
				if(obj.status == 'success'){
					$(".error").hide();
					$(".success").text(obj.msg);
					$(".success").fadeIn(1000);
				}else{
					$(".success").hide();
					$(".error").text("Notifikasi gagal disimpan...");
					$(".error").fadeIn(1000);
				}
				
				$.fancybox.hideActivity();
			},
			type: "POST"
		});
	}
	return false;
});
</script>